/**
 * Live GPS Tracking Application
 * Mathematical functions
 *
 * Copyright 2009, Ivar Clemens
 */

package nl.ivarclemens;

public class Math {

    public static double exp(double value, int ex)
    {
        double result = value;

        for(int i = 1; i < ex; i++)
            result = result * value;

        return result;
    }

    public static double log(double value)
    {
        double x = (value - 1) / (value + 1);
        double result = 0;

        for(int i = 1; i < 24; i += 2)
            result = result + Math.exp(x, i) / (double)i;

        return 2 * result;
    }

    public static double log10(double value)
    {
        return Math.log(value) / 2.3025850929940456840179914546844;
    }
}
